home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / oground.c < prev    next >
C/C++ Source or Header  |  1979-12-31  |  2KB  |  98 lines

  1. /* --------------------------------- oground.c ------------------------------ */
  2.  
  3. /* This is part of the flight simulator 'fly8'.
  4.  * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).
  5. */
  6.  
  7. /* Object description: ground.
  8. */
  9.  
  10. #include "fly.h"
  11.  
  12.  
  13. /* This object is a simple x-y reference grid that follows the plane.
  14. */
  15.  
  16. #define GUNIT    4000
  17. #define HORIZON    (0x07fffL*VONE)
  18.  
  19. static SHAPE shape_ground = {
  20.     0,
  21.     0,
  22.     0,
  23.     1L,        /* weight */
  24.     0        /* drag */
  25. };
  26.  
  27. LOCAL_FUNC int FAR
  28. init_ground (BODY *b)
  29. {
  30.     int    i, last, g, h;
  31.     VERTEX    *p, *vx_ground;
  32.  
  33.     i = (int)(HORIZON/VONE/GUNIT);
  34.     last = 2*i+1;
  35.  
  36.     if (!(vx_ground = (VERTEX *)memory_calloc (sizeof (*vx_ground),
  37.                                 4*last+1)))
  38.         return (1);
  39.  
  40.     shape_ground.v = vx_ground;
  41.     shape_ground.flags |= SH_DYNVERTEX;
  42.  
  43.     h = GUNIT*i;
  44.     for (g = -h, p = vx_ground, i = 0; i < last; ++i, g += GUNIT) {
  45.         p->V[X] = g;    p->V[Y] = -h;    p->V[Z] = 0;
  46.         p->flags = V_MOVE;    ++p;
  47.  
  48.         p->V[X] = g;    p->V[Y] = h;    p->V[Z] = 0;
  49.         p->flags = V_DRAW;    ++p;
  50.  
  51.         p->V[X] = -h;    p->V[Y] = g;    p->V[Z] = 0;
  52.         p->flags = V_MOVE;    ++p;
  53.  
  54.         p->V[X] = h;    p->V[Y] = g;    p->V[Z] = 0;
  55.         p->flags = V_DRAW;    ++p;
  56.     }
  57.     p->flags = 0;
  58.     return (0);
  59. }
  60.  
  61. LOCAL_FUNC int FAR
  62. create_ground (OBJECT *p)
  63. {
  64.     p->color = ST_GROUND;
  65.     p->time = FOREVER;
  66.     p->flags |= F_VISIBLE;
  67.     Mident (p->T);
  68.  
  69.     return (0);
  70. }
  71.  
  72. LOCAL_FUNC void FAR
  73. delete_ground (OBJECT *p)
  74. {}
  75.  
  76. LOCAL_FUNC void FAR
  77. dynamics_ground (OBJECT *p, int interval)
  78. {
  79.     p->R[X] = (((CV->R[X]/VONE+GUNIT/2)/GUNIT)*GUNIT)*VONE;
  80.     p->R[Y] = (((CV->R[Y]/VONE+GUNIT/2)/GUNIT)*GUNIT)*VONE;
  81. }
  82.  
  83. BODY FAR BoGround = {
  84.     0,
  85.     0,
  86.     "GROUND",
  87.     &shape_ground,
  88.     init_ground,
  89.     gen_term,
  90.     create_ground,
  91.     delete_ground,
  92.     dynamics_ground,
  93.     gen_hit
  94. };
  95.  
  96. #undef GUNIT
  97. #undef HORIZON
  98.